<?php echo $this->Html->script(array('print')); ?>

<div class="widget">

    <div class="whead"><h6>VISTA DE IMPRESION</h6><div class="clear"></div></div>
    <fieldset>
        <div id="areaImprimir">
            <table>
                <tr>
                    <td>
                        <?php echo $this->Html->image('epcm/logo1.png') ?>    
                    </td>
                    <td>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>
                        <h4>
                            <strong><?php echo $this->Session->read('Auth.User.Sucursale.nombre') ?></strong>
                        </h4>
                    </td>

                </tr>
                <tr>
                    <td>
                        <h6>
                            <strong style="color: #A64949">                               
                                NRO FACTURA :
                                <?php echo $notaremision['Notaremisione']['numero_factura']; ?>
                            </strong>
                        </h6>
                    </td>
                    <td colspan="2">
                        <h5>
                            <strong class="green">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                                
                                NOTA DE REMISION                                
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            </strong>
                        </h5>
                    </td>
                    <td>


                        <h6>
                            <strong style="color: #A64949">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                NUMERO : 
                                <?php echo $notaremision['Notaremisione']['numero']; ?>

                            </strong>
                        </h6>
                    </td>
                </tr>                
                <tr>
                    <td>
                        <h5>
                            Se&ntilde;or(es) : &nbsp;&nbsp;
                            <span>
                            <?php echo $cliente['Cliente']['nombre']; ?>
                        </span>
                        </h5>
                    </td>
                    <td>
                        
                    </td>
                    <td colspan="2">
                        <h5>
                        FECHA:
                        <?php
                            $tiempo = split(' ', $trabajo['Trabajo']['fecharegistro']);
                            $fecha = split('-', $tiempo[0]);
                            echo $fecha[2] . '-' . $fecha[1] . '-' . $fecha[0];
                        ?>
                        </h5>
                    </td>
                </tr>

                <tr>
                    <td><strong>Direccion:</strong></td>
                    <td><?php echo $cliente['Cliente']['telefono']; ?></td>
                    <td><strong>Telefono:</strong></td>
                    <td><?php echo $cliente['Cliente']['celular']; ?></td>	       	
                </tr>

            </table> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tLight">
<?php echo $this->Form->create('Hojasproduccione'); ?>

                <!--datos cabecera-->
                <thead>
                    <tr>
                        <td width="20%">Cantidad</td>
                        <td width="25%">Formato</td>
                        <td width="32%">Descripcion</td>
                        <td width="22%">Precio</td>
                    </tr>
                </thead>
                <!--//fin datos cabecera-->

                <!--Form datos hoja de produccion-->   
                <tbody>       
                    <tr>
<?php $total = 0;
foreach ($hoja as $h):
    ?>
                            <td><?php echo $h['Hojasproduccione']['cantidad']; ?></td>
                            <td>
                                <?php if ($h['Hojasproduccione']['tipo_id'] == 3): ?>
                                    <?php echo $h['Preciohoja']['nombre']; ?>
                                <?php else: ?>
                                    <?php echo $h['Hojasproduccione']['metrajeini']; ?>
                                    X
        <?php echo $h['Hojasproduccione']['metrajefin']; ?>
                                <?php endif; ?>
                            </td>

                            <td style="text-align:left">
    <?php echo $h['Hojasproduccione']['descripcion']; ?> -
                                <?php echo $h['Hojasproduccione']['tipo']; ?> -
                                <?php echo $h['Hojasproduccione']['cara']; ?>
                            </td>
                            <td style="text-align:right;">
                        <?php echo number_format($h['Hojasproduccione']['precio'], 2);
                        ;
                        ?>
                            </td>
                        </tr>
    <?php $total = $total + $h['Hojasproduccione']['precio']; ?>
                    <?php endforeach; ?>
                    <tr>
                        <td colspan="3">PRECIO TOTAL</td>
                        <td style="text-align:right; padding-right: 20px"><strong><?php echo number_format($total, 2); ?> Bs.</strong></td>      
                    </tr>
<?php if ($notaremision['Notaremisione']['tipo_pago'] == 'credito'): ?>
                        <tr>
                            <td colspan="4">
                                <div style="float: left">
                                    <h6 style="float: left;padding: 0px 35px 5px 20px"">Tipo de Pago</h6>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <small style="float: left; padding: 24px 35px 5px 20px">al Cr&eacute;dito</small>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <h6 style="float: left; padding: 0px 35px 5px 20px" ">Total cancelado</h6>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <small style="float: left; padding: 24px 35px 5px 20px">
    <?php echo number_format($notaremision['Notaremisione']['totalpagado'], 2); ?> Bs.
                                    </small>

                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </div>
                                <div style="float: right">
                                    <h6 style="float: left; padding: 0px 35px 5px 20px"" >Saldo</h6>
                                    <?php if ($notaremision['Notaremisione']['saldo'] != null || $notaremision['Notaremisione']['saldo'] != 0): ?>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <small style="float: left; padding: 24px 35px 5px 20px">
                                            <?php echo number_format($notaremision['Notaremisione']['saldo'], 2); ?> Bs.
                                        </small>
                                    <?php else: ?>
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <small style="float: left; padding: 24px 35px 5px 20px">
        <?php echo number_format($notaremision['Notaremisione']['totalpagado'], 2); ?> Bs.
                                        </small>
    <?php endif; ?>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                                </div>

                            </td>
                        </tr>

<?php else: ?>
                        <tr>
                            <td>Tipo de Pago</td>
                            <td>al Contado</td>
                            <td style="text-align:right; padding-right: 20px">
                                Saldo
                            </td>
                            <td style="text-align:right; padding-right: 20px">
                                0 Bs.
                            </td>
                        </tr>
<?php endif; ?>
                    <tr>
                        <td style="border: 0px solid black;"></td>
                        <td style="border: 0px solid black; height: 63px;"><strong> Entregado Por</td>
                        <td style="border: 0px solid black;"></td>
                        <td style="border: 0px solid black;"></td>
                    </tr>
                </tbody>  
            </table>
        </div>
    </fieldset>



</fieldset>
</div>
<table>
    <tr>
        <td> 
        <a class="buttonM bBlack" href="#" id="btnImprimir">IMPRIMIR</a>
        </td>
<?php if ($notaremision['Notaremisione']['numero_factura'] == 0): ?>
            <td> &nbsp;&nbsp;&nbsp;
             <a href="<?php echo $this->Html->url(array('action' => 'editaremisiones', $notaremision['Notaremisione']['id']))
                    ?>" class="buttonM bRed">
                        <span class="icol-pricetag2"></span><span>MODIFICAR NUMERO FACTURA</span>
                    </a>
            
            <?php //echo $this->Html->link('MODIFICAR NUMERO FACTURA', array('action' => 'editaremisiones', $notaremision['Notaremisione']['id'])) ?>
            </td>

<?php endif; ?>
        <td>&nbsp;&nbsp;&nbsp;
        <a href="<?php echo $this->Html->url(array('action' => 'editarnotaremisiones', $notaremision['Notaremisione']['id']))
                    ?>" class="buttonM bGreen">
                        <span class="icol-pricetag2"></span><span>EDITAR NOTA REMISION</span>
                    </a>
         
        <?php //echo $this->Html->link('EDITAR NOTA REMISION', array('action' => 'editarnotaremisiones', $notaremision['Notaremisione']['id'])) ?> 
        </td>
        <?php echo $this->Html->link("Atras", array('controller' => 'Trabajos', 'action' => 'verhojaproduccion'), array('class' => 'buttonS bLightBlue', 'escape' => FALSE)); ?>
        
    </tr>

</table>
<script type="text/javascript">

    $(document).ready(function() {

        $("#btnImprimir").click(function() {
            //console.log('click');
            printElem({
                leaveOpen: true,
                printMode: 'popup',
                overrideElementCSS: [
                    '<?php echo $this->webroot; ?>css/imprimir.css',
                    {href: '<?php echo $this->webroot; ?>css/imprimir.css', media: 'print'}]
            });
            //printElem({ overrideElementCSS: ['http://www.imprenta.com/css/printable.css'] });
        });

    });
    function printElem(options) {
        $('#areaImprimir').printElement(options);
    }
</script>